/**
 * Created by lenovo on 2017/5/8.
 * 店铺地址，联系信息组件
 */
import React from 'react';
// import ReactDOM from 'react-dom';

import positionUrl from '../img/imgBrandPage/position@2x.png';
import telUrl from '../img/imgBrandPage/Tel@2x.png';

class StorePageMessage extends React.Component {
    constructor(props) {
        super(props);
        this.goToMap = this.goToMap.bind(this);
        this.goToTel = this.goToTel.bind(this);
    }

    //跳转地图
    goToMap() {
        let options = {
            enableHighAccuracy: true,
            timeout: 5000,
            maximumAge: 0
        };

        function success(pos) {
            let crd = pos.coords;
            window.open('http://uri.amap.com/marker?position=' + crd.latitude + ',' + crd.longitude, '_self');
        }

        function error(err) {
            console.warn('ERROR(' + err.code + '): ' + err.message);
        }

        navigator.geolocation.getCurrentPosition(success, error, options);

    }

    //跳转电话
    goToTel() {
        document.getElementById('goToTel').click();
    }

    render() {
        const storeMessage = this.props.storeMessage;
        return (
            <div>
                <div className="cutLine"></div>

                <div className="storeDetailsContainer">
                    <div className="goToMapContent" onClick={this.goToMap}>
                        <img className="detailsImgPosition" src={positionUrl}/>
                        <span className="detailsFont">
                            {storeMessage.storeAddress}3 Swiss Ct, London W1D 6AP
                        </span>
                    </div>

                    <div onClick={this.goToTel} className="phoneContainer">
                        <a id="goToTel" className="xxx" href="tel://13764567708"></a>
                        <img className="detailsImgTel" src={telUrl}/>
                        {/*{storeMessage.storeTelephone}*/}
                    </div>
                </div>

            </div>
        )
    }

}

export default StorePageMessage;